﻿using System.IO;

namespace Flowertwig.Utils.Compression.General
{
    /// <summary>
    /// PathFilter filters directories and files by full path name.
    /// </summary>
    public class PathFilter : IScanFilter
    {
        /// <summary>
        /// Initialise a new instance of <see cref="PathFilter"></see>.
        /// </summary>
        /// <param name="filter">The <see cref="NameFilter"></see>filter expression to apply.</param>
        public PathFilter(string filter)
        {
            nameFilter = new NameFilter(filter);
        }

        /// <summary>
        /// Test a name to see if it matches the filter.
        /// </summary>
        /// <param name="name">The name to test.</param>
        /// <returns>True if the name matches, false otherwise.</returns>
        public virtual bool IsMatch(string name)
        {
            return nameFilter.IsMatch(Path.GetFullPath(name));
        }

        #region Instance Fields
        NameFilter nameFilter;
        #endregion
    }
}